Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5254 +/- ##
=======================================
Coverage 97.83% 97.84%
=======================================
Files 1008 1008
Lines 32590 32612 +22
Branches 12098 12114 +16
=======================================
+ Hits 31886 31908 +22
Misses 698 698
Partials 6 6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
The font-family override does not reach entered text when tokens are enabled because the paragraph reset prevents inheritance from the editable element.
1 open issue
What changed in this PR
Adds internal Style API v2 support to PromptInput, enabling custom styling in both native textarea and token modes.
Changes:
- Adds root and textarea slots, with forwarding to action buttons, tokens, and dropdown menus.
- Supports placeholder styling tokens, including disabled placeholder colors.
- Adds slot-forwarding unit tests and a demo page covering component states.
| File | Description |
|---|---|
src/prompt-input/tokens/use-token-mode.tsx |
Applies editable-element and inline-token classes. |
src/prompt-input/styles.scss |
Declares style slots and integrates placeholder tokens. |
src/prompt-input/internal.tsx |
Accepts and distributes style classes. |
src/prompt-input/components/token-mode.tsx |
Forwards menu styling to the dropdown container. |
src/prompt-input/__tests__/style-api.test.tsx |
Tests slot classes, forwarding, and DOM prop filtering. |
pages/prompt-input/style-api-v2.scss |
Defines custom styles for demo states and slots. |
pages/prompt-input/style-api-v2.page.tsx |
Demonstrates styling across native and token modes. |
Review effort: Balanced
294d5df to
15be9db
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Textarea height calculations still use stock padding and do not rerun when the slot class changes, potentially violating row limits and leaving content clipped or incorrectly sized.
2 open issues
1 resolved since last review
Review effort: Balanced
15be9db to
dbd09a3
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Changing only styleClassNames.token can alter token widths and wrapping without triggering height remeasurement, leaving the editable element at a stale fixed height even with maxRows={-1}.
2 open issues
1 resolved since last review
Review effort: Balanced
dbd09a3 to
5641959
Compare
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
5 open issues
ExportingStyleClassNamesfrominternal.tsxcan unintentionally expand the module’s public… · NewgetComputedStyle(element)is now called on everyadjustInputHeight()run, which can be on each… · New Keys on arrays of portals should be applied to the portal itself (the value returned by… · New Remeasure height when the reference-token class changes Calculate row limits using the textarea’s computed padding
Review effort: Lite
| // Style API v2 | ||
| export interface StyleClassNames { | ||
| root?: string; | ||
| textarea?: string; | ||
| actionButton?: string; | ||
| token?: string; | ||
| menu?: string; | ||
| } |
| // A Style API `padding` on the text element changes its block padding; add its difference from the | ||
| // stock padding to the row bounds so they still fit `minRows`/`maxRows` lines. The difference is 0 by default. | ||
| const computedStyle = getComputedStyle(element); | ||
| const paddingTop = toPaddingLength(computedStyle.paddingTop, designTokens.spaceFieldVertical); | ||
| const paddingBottom = toPaddingLength(computedStyle.paddingBottom, designTokens.spaceFieldVertical); | ||
| const paddingDelta = `(${paddingTop} + ${paddingBottom} - 2 * ${designTokens.spaceFieldVertical})`; | ||
| const minRowsHeight = isTokenMode | ||
| ? `calc(${minRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING})` | ||
| : `calc(${LINE_HEIGHT} + ${designTokens.spaceFieldVertical} * 2)`; | ||
| ? `calc(${minRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING} + ${paddingDelta})` | ||
| : `calc(${LINE_HEIGHT} + ${paddingTop} + ${paddingBottom})`; | ||
| const scrollHeight = `calc(${element.scrollHeight}px)`; | ||
|
|
||
| if (maxRows === -1) { | ||
| element.style.height = `max(${scrollHeight}, ${minRowsHeight})`; | ||
| } else { | ||
| const maxRowsHeight = `calc(${maxRows <= 0 ? DEFAULT_MAX_ROWS : maxRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING})`; | ||
| const maxRowsHeight = `calc(${maxRows <= 0 ? DEFAULT_MAX_ROWS : maxRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING} + ${paddingDelta})`; | ||
| element.style.height = `min(max(${scrollHeight}, ${minRowsHeight}), ${maxRowsHeight})`; | ||
| } |
| key={container.id} | ||
| variant="inline" | ||
| label={container.label} | ||
| disabled={!!disabled} | ||
| readOnly={!!readOnly} | ||
| styleClassNames={{ root: styleClassNames?.token }} | ||
| />, | ||
| container.element |
5641959 to
6ebc30f
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Textarea sizing can retain stale heights after focus or hover padding changes and clip requested rows with reduced or zero padding, requiring corrected bounds and browser sizing coverage.
6 open issues
Remeasure when interaction styles change textarea padding · New Preserve requested line heights with reduced textarea padding · New Keys on arrays of portals should be applied to the portal itself (the value returned by…getComputedStyle(element)is now called on everyadjustInputHeight()run, which can be on each… ExportingStyleClassNamesfrominternal.tsxcan unintentionally expand the module’s public… Calculate row limits using the textarea’s computed padding
1 resolved since last review
Review effort: Balanced
| const paddingTop = toPaddingLength(computedStyle.paddingTop, designTokens.spaceFieldVertical); | ||
| const paddingBottom = toPaddingLength(computedStyle.paddingBottom, designTokens.spaceFieldVertical); | ||
| const paddingDelta = `(${paddingTop} + ${paddingBottom} - 2 * ${designTokens.spaceFieldVertical})`; |
| const paddingDelta = `(${paddingTop} + ${paddingBottom} - 2 * ${designTokens.spaceFieldVertical})`; | ||
| const minRowsHeight = isTokenMode | ||
| ? `calc(${minRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING})` | ||
| : `calc(${LINE_HEIGHT} + ${designTokens.spaceFieldVertical} * 2)`; | ||
| ? `calc(${minRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING} + ${paddingDelta})` |
6ebc30f to
ea268fd
Compare
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the PromptInput Style API v2 changes.
5 open issues
Preserve requested line heights with reduced textarea padding Remeasure when interaction styles change textarea padding Keys on arrays of portals should be applied to the portal itself (the value returned by…getComputedStyle(element)is now called on everyadjustInputHeight()run, which can be on each… ExportingStyleClassNamesfrominternal.tsxcan unintentionally expand the module’s public…
1 resolved since last review
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
With maxRows={1} and zero block padding, the height cap falls below one full line of text, causing clipping or scrolling in both modes.
6 open issues
Add browser coverage for padding-aware sizing in both modes · New Preserve requested line heights with reduced textarea padding Remeasure when interaction styles change textarea padding Keys on arrays of portals should be applied to the portal itself (the value returned by…getComputedStyle(element)is now called on everyadjustInputHeight()run, which can be on each… ExportingStyleClassNamesfrominternal.tsxcan unintentionally expand the module’s public…
Review effort: Balanced
| const paddingTop = toPaddingLength(computedStyle.paddingTop, designTokens.spaceFieldVertical); | ||
| const paddingBottom = toPaddingLength(computedStyle.paddingBottom, designTokens.spaceFieldVertical); | ||
| const paddingDelta = `(${paddingTop} + ${paddingBottom} - 2 * ${designTokens.spaceFieldVertical})`; |

Description
Adds the internal Style API v2 to Prompt input:
root,textarea(the native textarea, or the editable element whentokensis set),actionButtonforwards to Button.root,tokenforwards to Token.root,menuforwards to Dropdown.container. Menu options have no slot and paint their own background, so a menu background shows only outside the options.Changes outside the component / behaviour changes:
src/prompt-input/styles.scss: the disabled placeholder (both modes) now reads--awsui-style-placeholder-colorwhen it is set; default rendering is unchanged.minRowsandmaxRowshold with a consumerpadding; padding or font set only under:hover,:focusor:focus-withinis measured at the next content, rows, density, width or class change. Default heights are unchanged. In token modep.paragraphinherits the font family of the text element.The style-docs snapshot and the VR registration of the dev page follow in one PR for all components.
Tracker section: P3d34KdbCd6o.
Related links, issue #, if available: n/a
How has this been tested?
Unit tests for every slot and forward, dev page
prompt-input/style-api-v2, build and lint green.Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.